/**
* eCommerce Application
* Implementation of DishBean
* @author Franck Chaix
*/

package ecom.beans.dish;

import ecom.beans.store.StoreEntity;


import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@NamedQueries({
    
    @NamedQuery(name = "findAllDishes",
    query = "SELECT dish FROM DishEntity dish"),
    
    @NamedQuery(name = "findDishById",
    query = "SELECT dish FROM DishEntity dish WHERE dish.id = :id"),
            
    @NamedQuery(name = "findDishByName",
    query = "SELECT dish FROM DishEntity dish WHERE dish.dishName = :dishName"),
            
    @NamedQuery(name = "findDishesByStoreId",
    query = "SELECT dish FROM DishEntity dish WHERE dish.store.id = :storeId")
})
@Entity
public class DishEntity implements java.io.Serializable{
	
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String dishName;
    private String dishType;
    private int quantity;
    private double price;
    private int calorieNumber;



    @ManyToOne
    private StoreEntity store;

    

    /****************************************************/
    
    public DishEntity() {}


    /****************************************************/
    
    public StoreEntity getStore() {
        return store;
    }

    public void setStore(StoreEntity store) {
        this.store = store;
    }
    
    public Long getDishId() {
        return this.id;
    }
    
    public void setDishId(Long dishId) {
        this.id = dishId;
    }
    
    public String getDishName() {
        return this.dishName;
    }
    
    public void setDishName(String dishName) {
        this.dishName = dishName;
    }

    public String getDishType() {
        return this.dishType;
    }
    
    public void setDishType(String dishType) {
        this.dishType = dishType;
    }
    
    public int getQuantity() {
        return this.quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public double getPrice() {
        return this.price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getCalorieNumber() {
        return this.calorieNumber;
    }

    public void setCalorieNumber(int calorieNumber) {
        this.calorieNumber = calorieNumber;
    }

    /****************************************************/
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DishEntity)) {
            return false;
        }
        DishEntity other = (DishEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.dish.DishEntity[id=" + id + "]";
    }

}
